﻿#include "function.h"


Function::Function(QDialog* parent, QString dir, int camera_index) : QDialog(parent)
{
    m_camera_index = camera_index;


    m_section = "common";

    m_dir = dir;

    QString path = dir +"/" + "camera" + QString::number(camera_index) + ".ini";

    m_qsettings = new QSettings(path, QSettings::IniFormat);


    m_section = "common";



    this->setWindowTitle("检测");
    QRect desktop_rect = QApplication::desktop()->geometry();
    double ratio_x = desktop_rect.width() / 1920.0;
    double ratio_y = desktop_rect.height() / 1080.0;

    move(0, 0);
    setFixedSize(1920 * ratio_x, 1010 * ratio_y);

    pixmapItem = new QGraphicsPixmapItem();

    m_listview = new QListView(this);
    m_listview->setSelectionBehavior(QAbstractItemView::SelectRows);	// 设置选择行为时每次选择一行
    m_listview->setEditTriggers(QAbstractItemView::NoEditTriggers);		// 设置不可编辑
    //m_listview->setStyleSheet("selection-background-color:lightblue;");	// 设置选中背景色
    m_listview->setGeometry(400 * ratio_x, 0, 240*ratio_x, 800 * 1.2 * ratio_y);
    m_listview_model = new QStringListModel();
    m_listview->setModel(m_listview_model);
    connect(m_listview, &QListView::clicked, this, &Function::listViewClick);

    m_view = new QtQGraphicsView(this);
    m_view->setGeometry(660 * ratio_x, 0, 1000 * 1.25 * ratio_x, 800 * 1.2 * ratio_y);

    QSize control_size(150 * ratio_x, 40 * ratio_y);

    QWidget* p = new QWidget(this);
    p->move(0 * ratio_x, 0 * ratio_y);
    p->setFixedSize(400 * ratio_x, 800 * ratio_y);

    QGridLayout* qgridLayout = new QGridLayout();
    p->setLayout(qgridLayout);

    int index = 0;



    QSize ButtonSize(150 * ratio_x, 40 * ratio_y);
    m_pushbutton_load_image = new QPushButton(this);
    m_pushbutton_load_image->setText("载入单张图像");
    m_pushbutton_load_image->setFixedSize(ButtonSize);
    connect(m_pushbutton_load_image, &QPushButton::clicked, this, [=]() {
        QString filename;
        filename = QFileDialog::getOpenFileName(this,
            tr("选择图像"),
            "",
            tr("Images (*.png *.bmp *.jpg)"));
        if (filename.isEmpty())
        {
            return;
        }

        m_image = imread(filename.toLocal8Bit().toStdString(), IMREAD_UNCHANGED);



        if (m_image.empty())
        {
            QMessageBox::information(nullptr, "", "加载检测图像错误");
            return;
        }

        QImage q_image = matToQImage(m_image);
        m_view->setImage(q_image, "",Qt::green, 20);
        });
    qgridLayout->addWidget(m_pushbutton_load_image, index, 0);

    m_pushbutton_load_dir = new QPushButton(this);
    m_pushbutton_load_dir->setText("载入图像目录");
    m_pushbutton_load_dir->setFixedSize(ButtonSize);
    connect(m_pushbutton_load_dir, &QPushButton::clicked, this, [=]() {
        QString directory;

        directory = QFileDialog::getExistingDirectory(this,
            tr("选择文件夹"),
            "");
        if (directory.isEmpty())
        {
            return;
        }

        QDir dir(directory);
        dir.setFilter(QDir::Files | QDir::NoSymLinks);
        QStringList filters;
        filters << "*.bmp" << "*.jpg" << "*.png";
        dir.setNameFilters(filters);



        QStringList  string_list = dir.entryList();
        QStringList string_list_path;
        foreach(QString  var, string_list) {
            string_list_path << directory + "/" + var;
        }

        m_listview_model->setStringList(string_list_path);
        });

    qgridLayout->addWidget(m_pushbutton_load_dir, index, 1);
    index++;




    if(camera_index==0)
    {
        m_function_scan = new FunctionScan(this, m_qsettings, "m_function_scan", camera_index);
        m_pushbutton_scan = new QPushButton(this);
        m_pushbutton_scan->setFixedSize(control_size);
        m_pushbutton_scan->setText("9006 块检测");
        connect(m_pushbutton_scan, &QPushButton::clicked, this, [=]() {

                if(m_unuse_use_scan==0)
                {
                     QMessageBox::critical(nullptr, "","OFF");
                     return;
                }
                if (m_image.empty())
                {
                    QMessageBox::information(nullptr, "", "no image");
                    return;
                }
                QString message;
                m_function_scan->m_image = m_image;
                m_function_scan->showDialog();
                m_function_scan->show();
                   });
         qgridLayout->addWidget(m_pushbutton_scan, index, 0);

         m_qcombobox_unuse_use_scan = new QComboBox(this);
         m_qcombobox_unuse_use_scan->setFixedSize(control_size);
         m_qcombobox_unuse_use_scan->addItem("OFF");
         m_qcombobox_unuse_use_scan->addItem("ON");

         qgridLayout->addWidget(m_qcombobox_unuse_use_scan, index, 1);

        index++;
    }
    /*if(camera_index==0)
    {
        m_function_blob_9007 = new FunctionBlob9007(this, m_qsettings, "m_function_blob_9007", camera_index);
        m_pushbutton_blob_9007 = new QPushButton(this);
        m_pushbutton_blob_9007->setFixedSize(control_size);
        m_pushbutton_blob_9007->setText("AI检测");
        connect(m_pushbutton_blob_9007, &QPushButton::clicked, this, [=]() {

                if(m_unuse_use_blob_9007==0)
                {
                     QMessageBox::critical(nullptr, "","OFF");
                     return;
                }
                if (m_image.empty())
                {
                    QMessageBox::information(nullptr, "", "no image");
                    return;
                }
                QString message;
                m_function_blob_9007->m_image = m_image;
                m_function_blob_9007->showDialog();
                m_function_blob_9007->show();
                   });
         qgridLayout->addWidget(m_pushbutton_blob_9007, index, 0);

         m_qcombobox_unuse_use_blob_9007 = new QComboBox(this);
         m_qcombobox_unuse_use_blob_9007->setFixedSize(control_size);
         m_qcombobox_unuse_use_blob_9007->addItem("OFF");
         m_qcombobox_unuse_use_blob_9007->addItem("ON");

         qgridLayout->addWidget(m_qcombobox_unuse_use_blob_9007, index, 1);

        index++;
    }*/

    if(camera_index==1)
    {
        m_function_blob_size = new FunctionBlobSize(this, m_qsettings, "m_function_blob_size", camera_index);
        m_pushbutton_blob_size = new QPushButton(this);
        m_pushbutton_blob_size->setFixedSize(control_size);
        m_pushbutton_blob_size->setText("面阵检测");
        connect(m_pushbutton_blob_size, &QPushButton::clicked, this, [=]() {

                if(m_unuse_use_blob_size==0)
                {
                     QMessageBox::critical(nullptr, "","OFF");
                     return;
                }
                if (m_image.empty())
                {
                    QMessageBox::information(nullptr, "", "no image");
                    return;
                }
                QString message;
                m_function_blob_size->m_image = m_image;
                m_function_blob_size->showDialog();
                m_function_blob_size->show();
                   });
         qgridLayout->addWidget(m_pushbutton_blob_size, index, 0);

         m_qcombobox_unuse_use_blob_size = new QComboBox(this);
         m_qcombobox_unuse_use_blob_size->setFixedSize(control_size);
         m_qcombobox_unuse_use_blob_size->addItem("OFF");
         m_qcombobox_unuse_use_blob_size->addItem("ON");
         
         qgridLayout->addWidget(m_qcombobox_unuse_use_blob_size, index, 1);

        index++;
    }

    if(camera_index==0 ||camera_index==4 )
    {
        m_function_dl = new Detection_dl(this, m_qsettings, "m_function_dl" + QString::number(camera_index));
        m_function_dl->m_image = m_image;

        m_pushbutton_dl = new QPushButton(this);
        m_pushbutton_dl->setFixedSize(control_size);
        m_pushbutton_dl->setText("深度学习检测");
        connect(m_pushbutton_dl, &QPushButton::clicked, this, [=]() {
            m_function_dl->m_image = m_image;
            m_function_dl->show();
            });
        qgridLayout->addWidget(m_pushbutton_dl, index, 0);

        m_qcombobox_unuse_use_dl = new QComboBox(this);
        m_qcombobox_unuse_use_dl->setFixedSize(control_size);
        m_qcombobox_unuse_use_dl->addItem("深度学习不启动");
        m_qcombobox_unuse_use_dl->addItem("深度学习启动");
        qgridLayout->addWidget(m_qcombobox_unuse_use_dl, index, 1);
        index++;
    }

    if(camera_index==0 )
    {
        m_function_dl_line_9007 = new FunctionDLLine9007(this, m_qsettings, "m_function_dl_line_9007" + QString::number(camera_index));
        m_function_dl_line_9007->m_image = m_image;

        m_pushbutton_dl_line_9007 = new QPushButton(this);
        m_pushbutton_dl_line_9007->setFixedSize(control_size);
        m_pushbutton_dl_line_9007->setText("9007 块检测");
        connect(m_pushbutton_dl_line_9007, &QPushButton::clicked, this, [=]() {
            m_function_dl_line_9007->m_image = m_image;
            m_function_dl_line_9007->show();
            });
        qgridLayout->addWidget(m_pushbutton_dl_line_9007, index, 0);

        m_qcombobox_unuse_use_dl_line_9007 = new QComboBox(this);
        m_qcombobox_unuse_use_dl_line_9007->setFixedSize(control_size);
        m_qcombobox_unuse_use_dl_line_9007->addItem("深度学习不启动");
        m_qcombobox_unuse_use_dl_line_9007->addItem("深度学习启动");
        qgridLayout->addWidget(m_qcombobox_unuse_use_dl_line_9007, index, 1);
        index++;
    }


    if(camera_index==1 )
    {
        m_function_dl_top = new DetectionDLTop(this, m_qsettings, "m_function_dl_top" + QString::number(camera_index));
        m_function_dl_top->m_image = m_image;

        m_pushbutton_dl_top = new QPushButton(this);
        m_pushbutton_dl_top->setFixedSize(control_size);
        m_pushbutton_dl_top->setText("深度学习毛边检测");
        connect(m_pushbutton_dl_top, &QPushButton::clicked, this, [=]() {
            m_function_dl_top->m_image = m_image;
            m_function_dl_top->show();
            });
        qgridLayout->addWidget(m_pushbutton_dl_top, index, 0);

        m_qcombobox_unuse_use_dl_top = new QComboBox(this);
        m_qcombobox_unuse_use_dl_top->setFixedSize(control_size);
        m_qcombobox_unuse_use_dl_top->addItem("深度学习不启动");
        m_qcombobox_unuse_use_dl_top->addItem("深度学习启动");
        qgridLayout->addWidget(m_qcombobox_unuse_use_dl_top, index, 1);
        index++;
    }


    if(camera_index==2 )
    {
        m_function_dl_3 = new Detection_dl_3(this, m_qsettings, "m_function_dl_" + QString::number(camera_index));
        m_function_dl_3->m_image = m_image;

        m_pushbutton_dl_3 = new QPushButton(this);
        m_pushbutton_dl_3->setFixedSize(control_size);
        m_pushbutton_dl_3->setText("深度学习");
        connect(m_pushbutton_dl_3, &QPushButton::clicked, this, [=]() {
            m_function_dl_3->m_image = m_image;
            m_function_dl_3->show();
            });
        qgridLayout->addWidget(m_pushbutton_dl_3, index, 0);

        m_qcombobox_unuse_use_dl_3 = new QComboBox(this);
        m_qcombobox_unuse_use_dl_3->setFixedSize(control_size);
        m_qcombobox_unuse_use_dl_3->addItem("深度学习不启动");
        m_qcombobox_unuse_use_dl_3->addItem("深度学习启动");
        qgridLayout->addWidget(m_qcombobox_unuse_use_dl_3, index, 1);
        index++;
    }


    m_qcombobox_save_wrong = new QComboBox(this);
    m_qcombobox_save_wrong->setFixedSize(control_size);
    m_qcombobox_save_wrong->addItem("不保存错误图像");
    m_qcombobox_save_wrong->addItem("保存错误图像");
    qgridLayout->addWidget(m_qcombobox_save_wrong, index, 0);


    m_qcombobox_save_right = new QComboBox(this);
    m_qcombobox_save_right->setFixedSize(control_size);
    m_qcombobox_save_right->addItem("不保存正确图像");
    m_qcombobox_save_right->addItem("保存正确图像");
    qgridLayout->addWidget(m_qcombobox_save_right, index, 1);

    index++;


    m_qcombobox_save_wrong_label = new QComboBox(this);
    m_qcombobox_save_wrong_label->setFixedSize(control_size);
    m_qcombobox_save_wrong_label->addItem("不保存错误标签图像");
    m_qcombobox_save_wrong_label->addItem("保存错误标签图像");
    qgridLayout->addWidget(m_qcombobox_save_wrong_label, index, 0);


    m_qcombobox_save_right_label = new QComboBox(this);
    m_qcombobox_save_right_label->setFixedSize(control_size);
    m_qcombobox_save_right_label->addItem("不保存正确标签图像");
    m_qcombobox_save_right_label->addItem("保存正确标签图像");
    qgridLayout->addWidget(m_qcombobox_save_right_label, index, 1);
    index++;

    m_pushbutton_save_parameter = new QPushButton(this);
    m_pushbutton_save_parameter->setFixedSize(control_size);
    m_pushbutton_save_parameter->setText("保存参数");
    connect(m_pushbutton_save_parameter, &QPushButton::clicked, this, &Function::saveParameter);
    qgridLayout->addWidget(m_pushbutton_save_parameter, index, 0);

    index++;
    m_pushbutton_show_orign_image = new QPushButton(this);
    m_pushbutton_show_orign_image->setFixedSize(ButtonSize);
    m_pushbutton_show_orign_image->setText("显示原图");
    connect(m_pushbutton_show_orign_image, &QPushButton::clicked, this, [=]() {
        QImage q_image = matToQImage(m_image);
        m_view->setImage(q_image, "",Qt::red, 20);
        return true;
    });
    qgridLayout->addWidget(m_pushbutton_show_orign_image, index, 0);
    m_pushbutton_detection = new QPushButton(this);
    m_pushbutton_detection->setFixedSize(control_size);
    m_pushbutton_detection->setText("检测");
    connect(m_pushbutton_detection, &QPushButton::clicked, this, &Function::detectionImage);
    qgridLayout->addWidget(m_pushbutton_detection, index, 1);
	index++;

	/*if (m_camera_index == 1)
	{
		m_pushbutton_detection2 = new QPushButton(this);
		m_pushbutton_detection2->setFixedSize(control_size);
		m_pushbutton_detection2->setText("再一次检测");
		connect(m_pushbutton_detection2, &QPushButton::clicked, this, &Function::detectionImage2);
		qgridLayout->addWidget(m_pushbutton_detection2, index, 0);
	}*/

    index++;
    m_pushbutton_return = new QPushButton(this);
    m_pushbutton_return->setFixedSize(control_size);
    m_pushbutton_return->setText("退出");
    qgridLayout->addWidget(m_pushbutton_return, index, 0);


    loadParameter(m_path_para, m_section);

    path = dir + "/" + "camera" + QString::number(m_camera_index) + ".png";
    m_image = imread(path.toLocal8Bit().toStdString(), -1);
    QImage q_image = matToQImage(m_image);
    m_view->setImage(q_image,"",Qt::red, 20);

}

bool Function::detection(Mat image_in, int index,QString& message)
{

    if (image_in.empty())
    {
        message += "检测图像为空 ";
        return false;
    }

    bool state = true;
    HObject hobject = matToHImage(image_in);
    
	if (0 == index)
	{
		if (m_unuse_use_blob_size && m_function_blob_size != nullptr)
		{
			state = m_function_blob_size->detection(hobject, message);
			if (state == false)
			{
				return false;
			}
		}
	}
	
    if (m_unuse_use_scan && m_function_scan!=nullptr)
    {
        state = m_function_scan->detection(hobject, message);
        if (state == false)
        {
            return false;
        }
    }

   /* if (m_unuse_use_blob_9007 && m_function_blob_9007!=nullptr)
    {
        state = m_function_blob_9007->detection(hobject, message);
        if (state == false)
        {
            return false;
        }
    }*/

    if (m_unuse_use_dl_3)
    {

        state = m_function_dl_3->detection(image_in, message);
        if (state < 1)
        {
            message += "AI检测错误";
            return false;
        }
    }


	if (m_unuse_use_dl_top)
	{

		state = m_function_dl_top->detection(image_in, message);
		if (state < 1)
		{
			message += "AI检测错误";
			return false;
		}
	}

	if (m_unuse_use_dl)
	{

		state = m_function_dl->detection(image_in, message);
		if (state < 1)
		{
			message += "AI检测错误";
			return false;
		}
	}
    if (m_unuse_use_dl_line_9007)
    {

        state = m_function_dl_line_9007->detection(image_in, message);
        if (state < 1)
        {
            message += "AI检测错误";
            return false;
        }
    }
    return true;
}

void  Function::detectionImage()
{
    if(m_image.empty())
    {
        QMessageBox::information(nullptr,"","没有图像");
        return;
    }

    QString message;
    bool state = false;
    if(m_unuse_use_function ==1)
		state = detection(m_image,0,message);

    Mat image_show;
    draw(m_image,image_show);

    QImage q_image = matToQImage(image_show);

    int font = 30;
	if (m_camera_index == 0)
        font = 60;
	if (m_camera_index == 1)
		font = 60;
	if (m_camera_index == 2)
		font = 40;
	if (state)
		m_view->setImage(q_image, message+"OK", Qt::green, font);
	else
		m_view->setImage(q_image, message+"NG", Qt::red, font);
    
}

//void  Function::detectionImage2()
//{
//	
//	if (m_image.empty())
//	{
//		QMessageBox::information(nullptr, "", "没有图像");
//		return;
//	}
//
//	QString message;
//	bool state = false;
//	if (m_unuse_use_function == 1)
//		state = detection(m_image, 1, message);
//
//	Mat image_show;
//	draw(m_image, image_show);
//
//	QImage q_image = matToQImage(image_show);
//
//	int font = 30;
//	if (m_camera_index == 0)
//		font = 10;
//	if (m_camera_index == 1)
//		font = 60;
//	if (m_camera_index == 2)
//		font = 40;
//	if (state)
//		m_view->setImage(q_image, message + "OK", Qt::green, font);
//	else
//		m_view->setImage(q_image, message + "NG", Qt::red, font);
//
//}

void Function::listViewClick(const QModelIndex& model_index)
{
    QString image_path = model_index.data().toString();

    m_image = imread(image_path.toLocal8Bit().toStdString(), IMREAD_UNCHANGED);

    if (m_image.empty())
    {
        QMessageBox::information(nullptr, "", "加载检测图像错误");
        return;
    }

    QImage q_image = matToQImage(m_image);
    m_view->setImage(q_image, "",Qt::green, 20);
}

void Function::draw(Mat image_in, Mat& image_out)
{
    image_out  = image_in;
    

    if (m_unuse_use_blob_size == 1 && m_function_blob_size!=nullptr)
    {
        m_function_blob_size->draw(image_in, image_out);
    }

    if (m_unuse_use_scan == 1 && m_function_scan!=nullptr)
    {
        m_function_scan->draw(image_out, image_out);
    }

   /* if (m_unuse_use_blob_9007 == 1 && m_function_blob_9007!=nullptr)
    {
        m_function_blob_9007->draw(image_out, image_out);
    }*/
	if (m_unuse_use_dl==1 && m_function_dl != nullptr)
	{
		m_function_dl->draw(image_out, image_out);
	}
    if (m_unuse_use_dl_line_9007==1 && m_function_dl_line_9007!= nullptr)
    {
        m_function_dl_line_9007->draw(image_out, image_out);
    }
    if (m_unuse_use_dl_3==1)
    {
        m_function_dl_3->draw(image_out, image_out);
    }

    if (m_unuse_use_dl_top==1)
    {
        m_function_dl_top->draw(image_out, image_out);
    }


    return;
}

void Function::loadParameter(QString path_in, QString section)
{
	m_path_para = path_in;
	m_section = section;
	try
	{
//		m_unuse_use_function = m_qsettings->value(section + "/" + "m_unuse_use_function").toInt();

		m_save_wrong = m_qsettings->value(section + "/" + "m_save_wrong").toInt();
		m_save_right = m_qsettings->value(section + "/" + "m_save_right").toInt();
		m_save_wrong_label = m_qsettings->value(section + "/" + "m_save_wrong_label").toInt();
		m_save_right_label = m_qsettings->value(section + "/" + "m_save_right_label").toInt();

//		m_qcombobox_unuse_use->setCurrentIndex(m_unuse_use_function);
		if(m_qcombobox_unuse_use_blob_size!=nullptr)
        {
            m_unuse_use_blob_size = m_qsettings->value(section + "/" + "m_unuse_use_blob_size").toInt();
			m_qcombobox_unuse_use_blob_size->setCurrentIndex(m_unuse_use_blob_size);
        }
        if(m_qcombobox_unuse_use_scan!=nullptr)
        {
            m_unuse_use_scan = m_qsettings->value(section + "/" + "m_unuse_use_scan").toInt();
            m_qcombobox_unuse_use_scan->setCurrentIndex(m_unuse_use_scan);
        }
       /* if(m_qcombobox_unuse_use_blob_9007!=nullptr)
        {
            m_unuse_use_blob_9007 = m_qsettings->value(section + "/" + "m_unuse_use_blob_9007").toInt();
            m_qcombobox_unuse_use_blob_9007->setCurrentIndex(m_unuse_use_blob_9007);
        }*/

		m_qcombobox_save_wrong->setCurrentIndex(m_save_wrong);
		m_qcombobox_save_right->setCurrentIndex(m_save_right);
		m_qcombobox_save_wrong_label->setCurrentIndex(m_save_wrong_label);
		m_qcombobox_save_right_label->setCurrentIndex(m_save_right_label);

        if(m_qcombobox_unuse_use_dl_3!=nullptr)
        {
            m_unuse_use_dl_3 = m_qsettings->value(section + "/" + "m_unuse_use_dl_3",0).toInt();
            m_qcombobox_unuse_use_dl_3->setCurrentIndex(m_unuse_use_dl_3);
            if(m_unuse_use_dl_3>0)
            {
                m_function_dl_3->loadmodel();
            }
        }
        if(m_qcombobox_unuse_use_dl_line_9007!=nullptr)
        {
	

            m_unuse_use_dl_line_9007 = m_qsettings->value(m_section + "/" + "m_unuse_use_dl_line_9007",0).toInt();
            m_qcombobox_unuse_use_dl_line_9007->setCurrentIndex(m_unuse_use_dl_line_9007);
            if(m_unuse_use_dl_line_9007>0)
            {
                m_function_dl_line_9007->loadmodel();
            }
        }
        if(m_function_dl_top!=nullptr)
        {
            m_unuse_use_dl_top = m_qsettings->value(section + "/" + "m_unuse_use_dl_top",0).toInt();
            m_qcombobox_unuse_use_dl_top->setCurrentIndex(m_unuse_use_dl_top);
            if(m_unuse_use_dl_top>0)
            {
                m_function_dl_top->loadmodel();
            }
        }
        if(m_qcombobox_unuse_use_dl!=nullptr)
        {
            m_unuse_use_dl = m_qsettings->value(section + "/" + "m_unuse_use_dl",0).toInt();
            m_qcombobox_unuse_use_dl->setCurrentIndex(m_unuse_use_dl);
            if(m_unuse_use_dl>0)
            {
                m_function_dl->loadmodel();
            }
        }
	}
	catch (exception& error)
	{
		QMessageBox::critical(nullptr, error.what(), m_section + "参数需要重新设置");
	}

	return;
}

void Function::saveParameter()
{
	try
	{
		if (!m_image.empty())
		{
			QString path = m_dir + "/" + "camera" + QString::number(m_camera_index) + ".png";
			imwrite(path.toLocal8Bit().toStdString(), m_image);
		}

//        m_unuse_use_function = m_qcombobox_unuse_use->currentIndex();

		m_save_wrong = m_qcombobox_save_wrong->currentIndex();
		m_save_right = m_qcombobox_save_right->currentIndex();
		m_save_wrong_label = m_qcombobox_save_wrong_label->currentIndex();
		m_save_right_label = m_qcombobox_save_right_label->currentIndex();
		//m_save_jpg_png = m_qcombobox_save_jpg_png->currentIndex();

//		m_qsettings->setValue(m_section + "/" + "m_unuse_use_function", m_unuse_use_function);

		if (m_qcombobox_unuse_use_blob_size != nullptr)
        {
            m_unuse_use_blob_size = m_qcombobox_unuse_use_blob_size->currentIndex();
			m_qsettings->setValue(m_section + "/" + "m_unuse_use_blob_size", m_unuse_use_blob_size);
        }

        if (m_qcombobox_unuse_use_scan != nullptr)
        {
            m_unuse_use_scan = m_qcombobox_unuse_use_scan->currentIndex();
            m_qsettings->setValue(m_section + "/" + "m_unuse_use_scan", m_unuse_use_scan);
        }

        /*if (m_qcombobox_unuse_use_blob_9007 != nullptr)
        {
            m_unuse_use_blob_9007 = m_qcombobox_unuse_use_blob_9007->currentIndex();
            m_qsettings->setValue(m_section + "/" + "m_unuse_use_blob_9007", m_unuse_use_blob_9007);
        }*/

		m_qsettings->setValue(m_section + "/" + "m_save_wrong", m_save_wrong);
		m_qsettings->setValue(m_section + "/" + "m_save_right", m_save_right);
		m_qsettings->setValue(m_section + "/" + "m_save_wrong_label", m_save_wrong_label);
		m_qsettings->setValue(m_section + "/" + "m_save_right_label", m_save_right_label);

        if (m_qcombobox_unuse_use_dl_3 != nullptr)
        {
            m_unuse_use_dl_3 = m_qcombobox_unuse_use_dl_3->currentIndex();
            m_qsettings->setValue(m_section + "/" + "m_unuse_use_dl_3", m_unuse_use_dl_3);
        }

        if (m_function_dl_top != nullptr)
        {
            m_unuse_use_dl_top = m_qcombobox_unuse_use_dl_top->currentIndex();
            m_qsettings->setValue(m_section + "/" + "m_unuse_use_dl_top", m_unuse_use_dl_top);
        }


        if (m_qcombobox_unuse_use_dl != nullptr)
        {
            m_unuse_use_dl = m_qcombobox_unuse_use_dl->currentIndex();
            m_qsettings->setValue(m_section + "/" + "m_unuse_use_dl", m_unuse_use_dl);
        }

        if (m_qcombobox_unuse_use_dl_line_9007 != nullptr)
        {
            m_unuse_use_dl_line_9007 = m_qcombobox_unuse_use_dl_line_9007->currentIndex();
            m_qsettings->setValue(m_section + "/" + "m_unuse_use_dl_line_9007", m_unuse_use_dl_line_9007);
        }
	}
	catch (exception& error)
	{
		QMessageBox::critical(nullptr, error.what(), m_section + "参数需要重新设置");
	}
}
